// pages/myExamStack/examRecordDetail/examRecordDetail.js
var util = require('../../../utils/util.js');
const config = require('../../../utils/config');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    examRecordDetail:[],
    examId: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.showLoading({
      title: '加载中...',
    })
    wx.request({
      url: config.examUrl + '/exam-history-histId',
      data: {
        histId: options.histId,
      },
      method: 'GET',
      header: {
        'content-type': 'application/json'
      },
      success: function(res) {
        console.log( res.data)
        var examRecordDetail = res.data;
        var examId = examRecordDetail[0].examId;
        console.log('examId====>>>>>>'+examId)
        if(examRecordDetail != null){
          wx.hideLoading();
          for(var i=0; i<examRecordDetail.length;i++){
            if(examRecordDetail[i].createTime != null ){
              examRecordDetail[i].createTime = util.formatTimeTwo(examRecordDetail[i].createTime,'Y-M-D h:m:s');
            } 
            if(examRecordDetail[i].effTime != null){
              examRecordDetail[i].effTime = util.formatTimeTwo(examRecordDetail[i].effTime,'Y-M-D h:m:s');
            }
            if(examRecordDetail[i].expTime != null){
              examRecordDetail[i].expTime = util.formatTimeTwo(examRecordDetail[i].expTime,'Y-M-D h:m:s');
            }
            if(examRecordDetail[i].submitTime != null){
              examRecordDetail[i].submitTime = util.formatTimeTwo(examRecordDetail[i].submitTime,'Y-M-D h:m:s');
            }
            if(examRecordDetail[i].verifyTime != null){
              examRecordDetail[i].verifyTime = util.formatTimeTwo(examRecordDetail[i].verifyTime,'Y-M-D h:m:s');
            }
          }
          that.setData({
            examRecordDetail: examRecordDetail,
            examId:examId
          })
        }
      },fail(){
        wx.hideLoading();
        wx.showToast({
          title: '系统错误',
          duration: 2000,
          image: '/images/erron.png',
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },


  //分析报告
  examBaogao:function(e){
    var that = this;
    console.log('that.data.examId......'+that.data.examId)
    wx.navigateTo({
      url: '../examBaogao/examBaogao?examId='+that.data.examId,
    })
  },

  //详细解答
  examJieda:function(e){
    var that = this;
    wx.navigateTo({
      url: '../userExamDetail/userExamDetail?examId='+that.data.examId,
    })
  },
})